<?php
include_once("connect.php");
//-----------------------------
//---include 
require( '../wp-load.php' );
//---get user_id
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
//$user_login = $current_user->user_login;
//---check if login
if ( !is_user_logged_in() || $user_id!=1 ) { 
	echo "<script language='javascript' type='text/javascript'>";  
	echo "$.fancybox.close();";  
	echo "</script>"; 
	exit;
} 
//-----------------------------
$id  = $_GET['id'];
if(!empty($id) && $id>0){
	$sql = "SELECT * FROM order_list WHERE id=$id";
	$rs = mysql_query($sql);
	if ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
		$fee_sum = $row['fee_sum'];
		$fee_currency_key = $row['fee_currency'];

	}
}


?>
<div class="fanbox">
    <h3>修改金额 (订单号：<?php echo $id; ?>)</h3>
    <form id="ch_fee_form" action="order_do.php?action=han_fee" method="post">
        <table width="100%" cellpadding="0" cellspacing="0" class="post_table">
            <tr>
                <td width="30%" align="right">支付币种：</td>
                <td>
					<select name="fee_currency">
						<option value="1" <?php if ($fee_currency_key==1) echo 'selected'; ?>>人民币</option>
						<option value="2" <?php if ($fee_currency_key==2) echo 'selected'; ?>>欧元</option>
					</select>
				</td>
            </tr>			

            <tr>
                <td width="30%" align="right">订单总金额：</td>
                <td>
					<input type="text" class="input1" id="fee_sum" name="fee_sum" maxlength="30" value="<?php echo $fee_sum; ?>" />
				</td>
            </tr>         
			
            <tr>
                <td colspan="2" align="center" >
					<input type="hidden" class="input2" name="order_id"  value="<?php echo $id; ?>" />
						
					<input type="submit" class="btn" value="提交"/> 
					<input type="button" class="btn" value="取消" onclick="$.fancybox.close();" />				
				</td>
            </tr>
			
			
        </table>
    </form>
</div>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(function(){
	$('#ch_fee_form').ajaxForm({
		beforeSubmit: validate,
		success: function(msg){
			if(msg>0){
				$.fancybox.close();				
				$().message("修改成功");
				self.location.reload();
			}else{
				alert(msg);
			}
		}
	}); 
});
function validate(formData, jqForm, options) { 	
	var s1 = document.getElementById("fee_sum").value;	
    if ( !if_num(s1) ) { 
		alert("金额必须为数值,请重新输入");
		document.getElementById("fee_sum").focus();
		return false; 
	} 
	$().message("正在提交...");
}


//---是否为数值,小数也算数值 
function if_num(value){
	var reg = /^\d+(\.\d+)?$/;   // 小数也算数值
	if(reg.test(value)==true){
		return true;
	}else{
		return false;
	}
}
//---是否为整数
function if_int(value){
	var reg=/^[1-9]\d*$|^0$/;   // 注意：故意限制了 0321 这种格式，如不需要，直接reg=/^\d+$/;
	if(reg.test(value)==true){
		return true;
	}else{
		return false;
	}
}
</script>